set more off

*use "C:\IRFAN\Research\Human Development\NITA\rudranooruddin2008.dta", clear
sort cowcode year
tsset cowcode year

summ pubemp_ratio_katy civilian_centgov soe_employees trade_gdp s18f1 imports_gdp exports_gdp /*
*/ gdppc_grow lngdppc  tot_unemp depend_ratio kaopen externalrisk polity2_di /*
*/ open6373 under_imf 

****************************************************************************************************
**  TABLE 1: DV = CHANGE IN PUBLIC EMPLOYMENT

* 	BASELINE MODEL (COLUMN 1)
xi:  reg d.pubemp_ratio_katy l.pubemp_ratio_katy d.trade_gdp l.trade_gdp /*
*/ gdppc_grow l.externalrisk polity2_di /*
*/ i.year i.cowcode, cluster(cowcode)

* 	 FOR SUPPLEMENTARY MATERIAL
tab ctryname if e(sample)
summ pubemp_ratio_katy civilian_centgov soe_employees trade_gdp imports_gdp exports_gdp /*
*/ gdppc_grow gdppc_grow lngdppc  tot_unemp depend_ratio kaopen externalrisk polity2_di /*
*/ open6373 l.under_imf if e(sample)

xi:  xtreg d.pubemp_ratio_katy l.pubemp_ratio_katy d.trade_gdp l.trade_gdp /*
*/ gdppc_grow l.externalrisk polity2_di /*
*/ lac, re cluster(cowcode)

* 	MODEL 1 (COLUMN 2)
xi:  reg d.pubemp_ratio_katy l.pubemp_ratio_katy d.trade_gdp l.trade_gdp /*
*/ gdppc_grow lngdppc  tot_unemp depend_ratio kaopen l.externalrisk polity2_di /*
*/ open6373 l.under_imf /*
*/ i.year i.cowcode, cluster(cowcode)

xi:  xtreg d.pubemp_ratio_katy l.pubemp_ratio_katy d.trade_gdp l.trade_gdp /*
*/ gdppc_grow lngdppc  tot_unemp depend_ratio kaopen l.externalrisk polity2_di /*
*/ open6373 l.under_imf /*
*/ lac, re cluster(cowcode)

* 	MODEL 2 (COLUMN 3) 
xi:  reg d.pubemp_ratio_katy l.pubemp_ratio_katy d.exports_gdp l.exports_gdp /*
*/ gdppc_grow lngdppc  tot_unemp  depend_ratio kaopen l.externalrisk polity2_di /*
*/ open6373 l.under_imf /*
*/ i.year i.cowcode, cluster(cowcode)

xi:  xtreg d.pubemp_ratio_katy l.pubemp_ratio_katy d.exports_gdp l.exports_gdp /*
*/ gdppc_grow lngdppc  tot_unemp  depend_ratio kaopen l.externalrisk polity2_di /*
*/ open6373 l.under_imf /*
*/ lac, re cluster(cowcode)

* MODEL 3 (COLUMN 4)
xi:  reg d.pubemp_ratio_katy l.pubemp_ratio_katy d.imports_gdp l.imports_gdp /*
*/ gdppc_grow lngdppc  tot_unemp  depend_ratio kaopen l.externalrisk polity2_di /*
*/ open6373 l.under_imf /*
*/ i.year i.cowcode, cluster(cowcode)

xi:  xtreg d.pubemp_ratio_katy l.pubemp_ratio_katy d.imports_gdp l.imports_gdp /*
*/ gdppc_grow lngdppc  tot_unemp  depend_ratio kaopen l.externalrisk polity2_di /*
*/ open6373 l.under_imf /*
*/ lac, re cluster(cowcode)

** DV = LEVEL OF PUBLIC EMPLOYMENT
* 	MODEL 4 (COLUMN 5)
xi:  reg pubemp_ratio_katy d.imports_gdp l.imports_gdp /*
*/ gdppc_grow lngdppc  tot_unemp  depend_ratio kaopen l.externalrisk polity2_di /*
*/ open6373 l.under_imf /*
*/ i.year i.cowcode, cluster(cowcode)

save, replace

****************************************************************************************************
** APPENDIX TABLE A1: USING GOVT CONSUMPTION AS ALT DV TO REPLICATE RODRIK

xi:  xtreg d.gg l.gg d.trade_gdp l.trade_gdp gdppc_grow  /*
*/ l.externalrisk polity2_di i.year , fe cluster(cowcode)
xi:  xtreg  d.gg l.gg d.trade_gdp l.trade_gdp gdppc_grow lngdppc  tot_unemp /*
*/ depend_ratio kaopen l.externalrisk polity2_di open6373 l.under_imf , fe cluster(cowcode)
xi:  xtreg  d.gg l.gg d.exports_gdp l.exports_gdp gdppc_grow lngdppc  tot_unemp /*
*/ depend_ratio kaopen l.externalrisk polity2_di open6373 l.under_imf i.year, fe cluster(cowcode)
xi:  xtreg  d.gg l.gg d.imports_gdp l.imports_gdp gdppc_grow lngdppc  tot_unemp /*
*/ depend_ratio kaopen l.externalrisk polity2_di open6373 l.under_imf i.year, fe cluster(cowcode)
xi:  xtreg gg d.imports_gdp l.imports_gdp /*
*/ gdppc_grow lngdppc  tot_unemp  depend_ratio kaopen l.externalrisk polity2_di /*
*/ open6373 l.under_imf /*
*/ i.year, fe cluster(cowcode)

xi:  xtreg d. finalconsumptionexpenditureetcof l. finalconsumptionexpenditureetcof d.trade_gdp l.trade_gdp gdppc_grow  /*
*/ l.externalrisk polity2_di i.year , fe cluster(cowcode)
xi:  xtreg d. finalconsumptionexpenditureetcof l. finalconsumptionexpenditureetcof d.exports_gdp l.exports_gdp gdppc_grow  /*
*/ l.externalrisk polity2_di i.year , fe cluster(cowcode)
xi:  xtreg d. finalconsumptionexpenditureetcof l. finalconsumptionexpenditureetcof d.imports_gdp l.imports_gdp gdppc_grow  /*
*/ l.externalrisk polity2_di i.year , fe cluster(cowcode)

****************************************************************************************************
** APPENDIX TABLE A2: BASELINE MODELS FOR EXPORTS AND IMPORTS

*	EXPORTS (COLUMN 1)
xi:  reg d.pubemp_ratio_katy l.pubemp_ratio_katy d.exports_gdp l.exports_gdp /*
*/ gdppc_grow l.externalrisk polity2_di /*
*/ i.year i.cowcode, cluster(cowcode)

*	IMPORTS (COLUMN 2)
xi:  reg d.pubemp_ratio_katy l.pubemp_ratio_katy d.imports_gdp l.imports_gdp /*
*/ gdppc_grow l.externalrisk polity2_di /*
*/ i.year i.cowcode, cluster(cowcode)
 
save, replace

****************************************************************************************************
** APPENDIX TABLE A4: RESULTS WITHOUT A LDV

xi:  reg  d.pubemp_ratio_katy d.trade_gdp l.trade_gdp gdppc_grow /*
*/ dl.externalrisk polity2_di i.year i.cowcode,  cluster(cowcode)
xi:  reg  d.pubemp_ratio_katy d.trade_gdp l.trade_gdp gdppc_grow lngdppc  tot_unemp /*
*/ depend_ratio kaopen l.externalrisk polity2_di open6373 l.under_imf i.year i.cowcode,  cluster(cowcode)
xi:  reg  d.pubemp_ratio_katy d.exports_gdp l.exports_gdp gdppc_grow lngdppc  tot_unemp /*
*/ depend_ratio kaopen l.externalrisk polity2_di open6373 l.under_imf i.year i.cowcode,  cluster(cowcode)
xi:  reg  d.pubemp_ratio_katy d.imports_gdp l.imports_gdp gdppc_grow lngdppc  tot_unemp /*
*/ depend_ratio kaopen l.externalrisk polity2_di open6373 l.under_imf i.year i.cowcode, cluster(cowcode)


****************************************************************************************************
*** DISAGGREGATING PUBLIC EMPLOYMENT 
**	TABLE 2: CIVILIAN CENTRAL GOVERNMENT

* 	TRADE (COLUMN 1)
reg civilian_centgov d.trade_gdp trade_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ if country~="Fiji"&year==1995|year==2000&country~="Fiji", cluster(cowcode) 
summ civilian_centgov if e(sample)

* 	EXPORTS (COLUMN 2)
reg civilian_centgov d.exports_gdp exports_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ if country~="Fiji"&year==1995|year==2000&country~="Fiji", cluster(cowcode) 

*	IMPORTS (COLUMN 3) 
reg civilian_centgov d.imports_gdp imports_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ if country~="Fiji"&year==1995|year==2000&country~="Fiji", cluster(cowcode) 

**	APPENDIX TABLE A9: CIVILIAN CENTRAL GOVERNMENT
reg civilian_centgov d.trade_gdp trade_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ depend_ratio kaopen externalrisk polity2_di open6373 under /* <-- EXTRA CONTROLS
*/ if year==1995|year==2000, cluster(cowcode) 

reg civilian_centgov d.exports_gdp exports_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ depend_ratio kaopen externalrisk polity2_di open6373 under /* <-- EXTRA CONTROLS
*/ if year==1995|year==2000, cluster(cowcode) 

reg civilian_centgov d.imports_gdp imports_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ depend_ratio kaopen externalrisk polity2_di open6373 under /* <-- EXTRA CONTROLS
*/ if year==1995|year==2000, cluster(cowcode) 


****************************************************************************************************
*** DISAGGREGATING PUBLIC EMPLOYMENT 
**	TABLE 3: SOE EMPLOYEES

* 	TRADE (COLUMN 1)
reg soe_employees d.trade_gdp trade_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ if year==1995|year==2000, cluster(cowcode) 
tab country if e(sample)
summ soe_employees if e(sample)

* 	EXPORTS (COLUMN 2)
reg soe_employees d.exports_gdp exports_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ if year==1995|year==2000, cluster(cowcode) 

*	IMPORTS (COLUMN 3) 
reg soe_employees d.imports_gdp imports_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ if year==1995|year==2000, cluster(cowcode) 


**	APPENDIX 4: SOE EMPLOYEES
reg soe_employees d.trade_gdp trade_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ depend_ratio kaopen externalrisk polity2_di open6373 under /* <-- EXTRA CONTROLS
*/ if cowcode~=710&year==1995|year==2000, cluster(cowcode) 

reg soe_employees d.exports_gdp exports_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ depend_ratio kaopen externalrisk polity2_di open6373 under /* <-- EXTRA CONTROLS
*/ if year==1995|year==2000, cluster(cowcode) 

reg soe_employees d.imports_gdp imports_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ depend_ratio kaopen externalrisk polity2_di open6373 under /* <-- EXTRA CONTROLS
*/ if year==1995|year==2000, cluster(cowcode) 

** NO CHINA
reg soe_employees d.trade_gdp trade_gdp /*
*/ gdppc_grow lngdppc tot_unemp lac /*
*/ if cowcode~=710&year==1995|year==2000, cluster(cowcode) 
reg soe_employees d.exports_gdp exports_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ if cowcode~=710&year==1995|year==2000, cluster(cowcode) 
reg soe_employees d.imports_gdp imports_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ if cowcode~=710&year==1995|year==2000, cluster(cowcode) 
 
** NO EGYPT
reg soe_employees d.trade_gdp trade_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ if cowcode~=651&year==1995|year==2000, cluster(cowcode) 
 
** NO CHINA & EGYPT
reg soe_employees d.trade_gdp trade_gdp /*
*/ gdppc_grow lngdppc tot_unemp /*
*/ if cowcode~=710&cowcode~=651&year==1995|year==2000, cluster(cowcode) 

 


save, replace

****************************************************************************************************
*** PUBLIC OPINION ON TRADE
**	TABLE 4: FAVOR INCREASING IMPORTS? (WVS DATA)

use "C:\Users\prltemp\Documents\My Dropbox\Research\Human Development\NITA\Paper #2\nooruddinrudra.replication data.table 4.dta", clear
/*
edit hyp year ctrycode socspending pubemp_ratio_katy married numchildren age_3cat female chiefwageemp educlevel lowerclass middleclass upperclass /*
*/ prlower prmiddle prupper if hyp==1
*/

*	TABLE 4 

** 	FULL SAMPLE 

*   BASELINE MODEL(COLUMN 1)
logit favorimports pubemp_ratio_katy socspending lowerclass middleclass married numchildren /*
*/ age_3cat female chiefwageemp educlevel, cluster(ctrycode) nolog
fitstat

* 	FOR SUPPLEMENTARY MATERIAL
tab ctrycode if e(sample)
summ favorimports pubemp_ratio_katy socspending lowerclass middleclass married numchildren /*
*/ age_3cat female chiefwageemp educlevel if e(sample)

**  INTERACTION (COLUMN 1) 
*gen pubempXlowerclass = pubemp_ratio_katy*lowerclass
*gen pubempXmiddleclass = pubemp_ratio_katy*middleclass
logit favorimports pubemp_ratio_katy socspending lowerclass pubempXlowerclass middleclass pubempXmiddleclass /*
*/ married numchildren age_3cat female  /*
*/ chiefwageemp educlevel, cluster(ctrycode) nolog
fitstat

** BY SOCIAL CLASS

*	LOWER CLASS ONLY (COLUMN 1)
logit favorimports pubemp_ratio_katy socspending  married numchildren /*
*/ age_3cat female chiefwageemp educlevel if lowerclass==1, cluster(ctrycode) nolog
predict prlower
fitstat

*	MIDDLE CLASS ONLY (COLUMN 1)
logit favorimports pubemp_ratio_katy socspending married numchildren /*
*/ age_3cat female chiefwageemp educlevel if middleclass==1, cluster(ctrycode)
predict prmiddle
fitstat

* 	UPPER CLASS ONLY (COLUMN 1)
logit favorimports pubemp_ratio_katy socspending  married numchildren /*
*/ age_3cat female chiefwageemp educlevel if upperclass==1, cluster(ctrycode)
predict prupper
fitstat

*	PREDICTED PROBABILITIES
*drop prlower prmiddle prupper
browse hyp year ctrycode socspending pubemp_ratio_katy lowerclass middleclass upperclass prlower prmiddle prupper if hyp==1

